package dao;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.util.Collection;

import model.ModelBase;

public interface DAO<T> {

	static final String CSV = "csv";
	static final String FIXED = "fixed";
	static final String SERIAL = "serialization";
	static final String MYSQL = "mysql";
	static final String XMLSAX = "sax";
	static final String XMLDOM = "dom";

	/**
	 * @param in
	 * @return
	 * @throws IOException
	 */
	T read(InputStream in) throws IOException;

	/**
	 * @param out
	 * @param data
	 * @throws IOException
	 */
	void write(OutputStream out, T data) throws IOException;

	/**
	 * @param in
	 * @return
	 * @throws IOException
	 */
	Collection<T> readMultiple(InputStream in) throws IOException;

	/**
	 * @param out
	 * @param data
	 * @throws IOException
	 */
	void writeMultiple(OutputStream out, Collection<T> data) throws IOException;

	/**
	 * @param connection
	 * @param data
	 * @return
	 */
	int save(Connection connection, ModelBase data);

	/**
	 * @param connection
	 * @param data
	 * @return
	 */
	int delete(Connection connection, ModelBase data);
}
